package com.preskool.service.impl;

import com.preskool.dto.ExamVo;
import com.preskool.mapper.ExamMapper;
import com.preskool.po.Exam;
import com.preskool.po.ExamExample;
import com.preskool.service.ExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * TODO
 *
 * @author ZhaoBo
 * @description:
 * @date 2021/1/7  20:08
 */
@Service
public class ExamServieImpl implements ExamService {

    @Autowired
    private ExamMapper examMapper;

    /**
     * 查询全部考试清单
     * @return
     */
    @Override
    public List<ExamVo> findExams(Integer offset,Integer limit,Object orderByClause) {
        ExamExample example = new ExamExample();
        offset = (offset - 1) * limit;
        example.setOffset(offset);
        example.setLimit(limit);
        example.getOrderByClause(orderByClause);
        List<ExamVo> exams = examMapper.selectAllExams(example);
        return exams;
    }

    /**
     * 添加一条考试清单数据
     * @return
     */
    @Override
    public int insertExam(Exam exam) {
            int i = examMapper.insertSelective(exam);
            return i;
    }

    /**
     * 删除一条考试清单
     * @param examid
     * @return
     */
    @Override
    public int delExam(Integer examid) {
        int i = examMapper.deleteByPrimaryKey(examid);
        return i;
    }

    /**
     * 修改一条考试清单
     * @param exam
     * @return
     */
    @Override
    public int updateExam(Exam exam) {

        int i = examMapper.updateByPrimaryKeySelective(exam);
        return i;
    }
}
